home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 July / Disc 1 / PCU0703CD1.iso / tutorial / macromed / files / director / embedded_files / globalnav.js < prev    next >
Encoding:
JavaScript  |  2003-05-08  |  2.1 KB  |  73 lines

  1. /* 
  2.     Copyright (c) 2002-2003 Macromedia, Inc. 
  3.     globalnav scripts    
  4.     Language: JavaScript 1.2
  5.     
  6. */
  7.  
  8. // called by globalnav.swf 
  9. // sets the mediapref cookie
  10. function setFlash(flash_version_string) {
  11.     var pixelName = 'flash_pixel';
  12.     if (document[pixelName] && flash_version_string) {
  13.         document[pixelName].src = '/set_media_pref?'+flash_version_string;
  14.     }
  15. }
  16. function defineFunctions() {
  17.     if (!document.getElementById) {
  18.         if (document.layers) document.getElementById = function() { return; }
  19.         if (document.all) document.getElementById = function(str) { return document.all[str]; }
  20.     }
  21. }
  22. function positionContent(y) {
  23.     var contentBox = document.getElementById('contentWrapper');
  24.     if (y && contentBox) {    
  25.         contentBox.style.top = y + 'px';
  26.     }
  27. }
  28. function calcGlobalnavHeight() {
  29.     var globalmessage = document.getElementById('globalmessage');
  30.     var gma_height = (globalmessage != null) ? globalmessage.height : 0;
  31.     var height = 64 + gma_height + 8;
  32.     return height;
  33. }
  34. //
  35. //
  36. function setSWFHeight(h) {
  37.     if (document.getElementById('globalnav-object') != null) {
  38.         document.getElementById('globalnav-object').setAttribute('height',h);
  39.     }    
  40.     if (document.getElementById('globalnav-embed') != null) {
  41.         document.getElementById('globalnav-embed').setAttribute('height',h);
  42.     }
  43. }
  44. //
  45. function initPage() {
  46.     defineFunctions();    
  47.     if (!document.getElementById('globalnav-object') &&
  48.             !document.getElementById('globalnav-embed') &&
  49.             !document.getElementById('globalnav-primary') && 
  50.             !document.getElementById('global-message')) {    
  51.         positionContent(calcGlobalnavHeight());
  52.     } 
  53. /*
  54.     else { // check for swf globalnav
  55.         var isNew;
  56.         if (document.getElementById('globalnav-object') != null) {
  57.             var params = document.getElementsByTagName('param');
  58.             for (var i=0; i<params.length; i++) {
  59.                 if (params[i].value.indexOf('2tier_en_us') != -1) isNew = true; 
  60.             }
  61.         }
  62.         if (document.getElementById('globalnav-embed') != null) {
  63.             var swf = new String(document.getElementById('globalnav-embed').src);
  64.             if (swf.indexOf('en_us') != -1) isNew = true;
  65.         }
  66.         if (isNew == false) {
  67.             window.setTimeout('setSWFHeight(64)',200);
  68.             positionContent(72);
  69.         }
  70.     }
  71. */
  72. }
  73.